package controllers.cms.pages;

import java.util.Map;

import models.cms.BlockDto;
import models.cms.PageDto;
import play.api.templates.Html;
import controllers.cms.CmsException;
import controllers.cms.TemplateResolver;

public class PageManagerImpl extends AbstractPageManager implements PageManager {

	@Override
	public Html render(PageDto page) throws CmsException {
		
		Map<String, BlockDto> blocks = page.getBlocks();
		for(String zone : blocks.keySet()){
			BlockDto bloc = blocks.get(zone);
			page.addRenderBlocks(zone, renderBlock(page, bloc));
		}
		return TemplateResolver.render(page);
	}
}
